package com.gitee.swsk33.catserviceconsumer.api;

import com.gitee.swsk33.catentity.dataobject.Cat;
import com.gitee.swsk33.catentity.model.Result;
import com.gitee.swsk33.catserviceconsumer.feignclient.CatClient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/cat")
public class CatAPI {

	@Autowired
	private CatClient catClient;

	@PostMapping("/add")
	public Result add(@RequestBody Cat cat) {
		return catClient.add(cat);
	}

	@DeleteMapping("/delete/{id}")
	public Result delete(@PathVariable("id") int id) {
		return catClient.delete(id);
	}

	@PutMapping("/update")
	public Result update(@RequestBody Cat cat) {
		return catClient.update(cat);
	}

	@GetMapping("/get/{id}")
	public Result<Cat> getCat(@PathVariable("id") int id) {
		return catClient.getCat(id);
	}

}